]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
workspaceAnimation: Sync progress with main adjustment
authorGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Thu, 10 Aug 2023 19:59:00 +0000 (16:59 -0300)
committerMarge Bot <marge-bot@gnome.org>
Fri, 11 Aug 2023 16:51:13 +0000 (16:51 +0000)
Create a derived workspaces adjustment using the new API, and
bind it to the 'progress' property. This is only done by the
MonitorGroup representing the primary monitor.

The progress value that WorkspaceAnimation operates on
represents the percentage within the workspaceIndices array
we are, so make sure to transform the percentage to the
correct workspace index.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2881>

js/ui/workspaceAnimation.js

index 93be07e2cd1e2b5c77a1e7f822a90223cffef123..5a4fe3ba36dae42f80d53de6adb1f418d3ae9061 100644 (file)
@@ -9,6 +9,7 @@ import St from 'gi://St';
 import * as Background from './background.js';
 import * as Layout from './layout.js';
 import * as SwipeTracker from './swipeTracker.js';
+import * as Util from '../misc/util.js';
 
 import * as Main from './main.js';
 
@@ -187,6 +188,25 @@ const MonitorGroup = GObject.registerClass({
         }
 
         this.progress = this.getWorkspaceProgress(activeWorkspace);
+
+        if (monitor.index === Main.layoutManager.primaryIndex) {
+            this._workspacesAdjustment = Main.createWorkspacesAdjustment(this);
+            this.bind_property_full('progress',
+                this._workspacesAdjustment, 'value',
+                GObject.BindingFlags.SYNC_CREATE,
+                (bind, source) => {
+                    const indices = [
+                        workspaceIndices[Math.floor(source)],
+                        workspaceIndices[Math.ceil(source)],
+                    ];
+                    return [true, Util.lerp(...indices, source % 1.0)];
+                },
+                null);
+
+            this.connect('destroy', () => {
+                delete this._workspacesAdjustment;
+            });
+        }
     }
 
     get baseDistance() {